package com.Liux.service.user;

import com.Liux.dao.BaseDao;
import com.Liux.dao.user.UserDao;
import com.Liux.dao.user.UserDaoImpl;
import com.Liux.pojo.User;

import java.sql.Connection;
import java.sql.SQLException;

public class UserServiceImpl implements UserService {

    //业务层都会调用dao层，所以我们要引入Dao层
    private UserDao userDao;


    public UserServiceImpl(){
        userDao = new UserDaoImpl();
    }

    public User login(String userCode,String password){
        Connection connection=null;
        User user = null;


        try {
            connection = BaseDao.getConnection();
            //通过业务层调用对应的具体的数据库操作
            user = userDao.getLoginUser(connection,userCode);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
            BaseDao.closeResource(connection,null,null);
        }
        return user;

    }
}
